<template>
	<view class="home" >
		<my-header bgColor="bg-gradual-blue" >
			<block slot="content">首页</block>
		</my-header>
        <view class="bgHeader"></view>
        <swiper class="card-swiper" :class="dotStyle?'square-dot':'round-dot'" :indicator-dots="true" :circular="true"
		 :autoplay="true" interval="5000" duration="500" @change="cardSwiper" indicator-color="#8799a3"
		 :indicator-active-color="col">
			<swiper-item v-for="(item,index) in swiperList" :key="index" :class="cardCur==index?'cur':''">
				<view class="swiper-item" @click="go(item.link)">
					<image :src="item.url" mode="aspectFill" ></image>
					<!-- <video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false" objectFit="cover" v-if="item.type=='video'"></video> -->
					<view class="swiper_title .cu-bar  .bg-shadeBottom" v-if="item.title">{{item.title}}</view>
				</view>
			</swiper-item>
		</swiper>
		<view class="example-body" v-if="notice.title" @click="go(notice.link)">
			<uni-notice-bar :show-close="false" :show-icon="true" :scrollable="true" :single="true" :show-get-more="notice.link" :text="notice.title" />
		</view>
        <view class="navList"></view>
        <view class="cu-bar bg-white solid-bottom ">
			<view class="action">
				<text class="cuIcon-titles text-orange "></text> 记录分享
			</view>
			<view class="action row" @click="go(router.art_list)">
				查看更多
				<view class="cuIcon-right right"></view>
			</view>
		</view>
		<view class="cu-card article no-card" :class="isCard?'no-card':''">
            <block v-for="(item,index) in articleList" :key="index">
                <view class="cu-item shadow" @click="goDetails(item)">
				<view class="title" style="line-height:80rpx;"><view class="text-cut">{{item.title}}</view></view>
				<view class="content">
					<image :src="item.main_img"
					 mode="aspectFill"></image>
					<view class="desc">
						<view class="text-content" :style="'height:'+3*1.6+'em;'"> 
                            {{item.abstract}}
                        </view>
						<!-- <view>
							<view class="cu-tag bg-red light sm round">正义天使</view>
							<view class="cu-tag bg-green light sm round">史诗</view>
						</view> -->
						<view class="text-gray text-sm row flex justify-between">
							{{item.add_time}}
							<view class="text-gray text-sm padding-right-xs margin-bottom-xs" >
								<text class="cuIcon-attentionfill margin-right-xs margin-left"></text> {{item.view}}
								<!-- <text class="cuIcon-appreciatefill margin-right-xs margin-left"></text> {{item.zan}}
								<text class="cuIcon-messagefill margin-right-xs margin-left"></text> {{item.ping.length}} -->
							</view>
						</view>
					</view>
				</view>
			</view>
            </block>
			
		</view>
        <!-- <view class="go" @click="go('/bill/pages/app/bookkeeping/bookkeeping')">账单</view> -->
        <!-- <loading v-if="!huangli"></loading> -->
		<!-- <my-footer cur="0"></my-footer> -->
	</view>
</template>
<script>
	import router from "../router";
	import uniNoticeBar from '@/components/uni-notice-bar/uni-notice-bar.vue'
	export default {
		components: {
			uniNoticeBar,
		},
		data() {
			return {
                col:getApp().globalData.col,
                cardCur: 0,
                swiperList: [],
                articleList:[], 
				dotStyle: false,
				towerStart: 0,
				direction: '',
				router:{},
				is_ipX:getApp().is_ipX,
                
			}
        },
        props:{
            notice:{
                type:Object
            }
        },
		
		created(){
            this.initData()	
			this.router=router
			// this.go(router.screen)
        },
		methods: {
			async initData(){
                const res=await uni.$request({
                },"api/applet/home")
                if (res.code==200) {
					console.log(res);
                    this.swiperList=res.data.swiperList
					this.articleList=res.data.articleList
					// this.goDetails(res.data.articleList[0])
                }
				
            },
            goDetails(item){
                let url=router.article+"?id="+item.id
                if (item.link) {
                    url=router.webview+"?link="+item.link
				}
				console.log(url);
                uni.$go(url);
            },
			go(url){
				console.log(url);
	 			uni.navigateTo({
					url,
					success:(res)=>{
						console.log(res);
					},
					fail:(err)=>{
						console.log(err);
						// uni.$err(url+"不在app.json")
					}
				});
				
			},
			DotStyle(e) {
				this.dotStyle = e.detail.value
			},
			// cardSwiper
			cardSwiper(e) {
				this.cardCur = e.detail.current
			},
		}
	}
</script>

<style lang="scss">
    @import "../main";
    
</style>